package com.hjm.project.qbMerWithdrawal.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.qbMerWithdrawal.domain.QbMerWithdrawal;
import com.hjm.project.qbMerWithdrawal.service.IQbMerWithdrawalService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 钱宝对账文件Controller
 * 
 * @author maker-platform
 * @date 2022-03-11
 */
@Controller
@RequestMapping("/qbMerWithdrawal/qbMerWithdrawal")
public class QbMerWithdrawalController extends BaseController {
    private String prefix = "qbMerWithdrawal";

    @Resource
    private IQbMerWithdrawalService qbMerWithdrawalService;

    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:view")
    @GetMapping()
    public String qbMerWithdrawal() {
        return prefix + "/qbMerWithdrawal";
    }

    /**
     * 查询钱宝对账文件列表
     */
    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QbMerWithdrawal qbMerWithdrawal) {
        startPage();
        List<QbMerWithdrawal> list = qbMerWithdrawalService.selectQbMerWithdrawalList(qbMerWithdrawal);
        return getDataTable(list);
    }

    /**
     * 导出钱宝对账文件列表
     */
    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:export")
    @Log(title = "钱宝对账文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QbMerWithdrawal qbMerWithdrawal) {
        List<QbMerWithdrawal> list = qbMerWithdrawalService.selectQbMerWithdrawalList(qbMerWithdrawal);
        ExcelUtil<QbMerWithdrawal> util = new ExcelUtil<QbMerWithdrawal>(QbMerWithdrawal.class);
        return util.exportExcel(list, "qbMerWithdrawal");
    }

    /**
     * 新增钱宝对账文件
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存钱宝对账文件
     */
    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:add")
    @Log(title = "钱宝对账文件", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QbMerWithdrawal qbMerWithdrawal) {
        return toAjax(qbMerWithdrawalService.insertQbMerWithdrawal(qbMerWithdrawal));
    }

    /**
     * 修改钱宝对账文件
     */
    @GetMapping("/edit/{msgType}")
    public String edit(@PathVariable("msgType") String msgType, ModelMap mmap) {
        QbMerWithdrawal qbMerWithdrawal = qbMerWithdrawalService.selectQbMerWithdrawalById(msgType);
        mmap.put("qbMerWithdrawal", qbMerWithdrawal);
        return prefix + "/edit";
    }

    /**
     * 修改保存钱宝对账文件
     */
    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:edit")
    @Log(title = "钱宝对账文件", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QbMerWithdrawal qbMerWithdrawal) {
        return toAjax(qbMerWithdrawalService.updateQbMerWithdrawal(qbMerWithdrawal));
    }

    /**
     * 删除钱宝对账文件
     */
    @RequiresPermissions("qbMerWithdrawal:qbMerWithdrawal:remove")
    @Log(title = "钱宝对账文件", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(qbMerWithdrawalService.deleteQbMerWithdrawalByIds(ids));
    }
}
